package com.haochu.xxl.util;

import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by Administrator on 2017/10/5.
 * bitmap工具类
 */
public class BitmapUtil {

    /**
     * 从assets目录获取bitmap
     */
    public static Bitmap getFromAssets(Resources resources, String path) {
        Bitmap image = null;
        AssetManager am = resources.getAssets();
        try {
            InputStream is = am.open(path);
            image = BitmapFactory.decodeStream(is);
            is.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return image;
    }


}
